<?php
/**
 * Created by PhpStorm.
 * User: stupboy
 * Date: 2018/4/15
 * Time: 23:05
 * Mail:87658989@qq.com
 */

namespace app\base\service;

use phpmailer\PHPMailer;

class Mail
{
    static public function markDebug($title,$value){
        $arr = [
            'title'=>$title,
            'content'=>$value
        ];
        Redis::getInstance()->push('car_mail_debug',serialize($arr));
    }

    public function send($title='BUG',$content='BUG'){
        try{
            $mail = new PHPMailer();
            //邮件调试模式
            // $mail->SMTPDebug = 2;
            //设置邮件使用SMTP
            $mail->isSMTP();
            // 设置邮件程序以使用SMTP
            $mail->Host     = 'smtp.sina.com';
            // 设置邮件内容的编码
            $mail->CharSet  ='UTF-8';
            // 启用SMTP验证
            $mail->SMTPAuth = true;
            // SMTP username
            $mail->Username = 'stupboy';
            // SMTP password
            $mail->Password = 'jwy871018';
            $mail->setFrom('stupboy@sina.com', 'BUG自动反馈');
            $mail->addAddress('87658989@qq.com', 'bugger');     // Add a recipient
            $mail->addCC('hjklrchang@qq.com', 'LRChang');
            $mail->addReplyTo('stupboy@sina.com', 'BUG反馈');
            $mail->isHTML(true);
            $mail->Subject = $title;
            $mail->Body = $content;
            $mail->send();
            $mail->isSMTP();
        }catch (\phpmailer\Exception $e){
            return $e->getMessage();
        }
    }
}